home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / dsclass_install next >
Encoding:
Text File  |  1989-10-10  |  9.6 KB  |  391 lines

  1. #!/bin/csh
  2. # Installation c-shell script written by Swan Kim 5/1989
  3. # The file "installcap" should exist in the current working directory
  4. #
  5. set curdir = `pwd`
  6.  
  7. set oldhomedir = `grep HOMEDIR installcap | awk '{print $2}'`
  8. set oldtopdir = `grep TOPDIR installcap | awk '{print $2}'`
  9. set oldpackagedir = `grep PACKAGEDIR installcap | awk '{print $2}'`
  10. set oldpackagename = `grep PACKAGENAME installcap | awk '{print $2}'`
  11. set oldpackagename = `grep PACKAGENAME installcap | awk '{print $2}'`
  12. set oldprintername = `grep PRINTERNAME installcap | awk '{print $2}'`
  13. set oldsunos = `grep SUNOS installcap | awk '{print $2}'`
  14. set oldfpflags = `grep FPFLAGS installcap | awk '{print $2}'`
  15. set oldmathlibs = `grep MATHLIBS installcap | awk '{print $2}'`
  16.  
  17. echo '------------------------------------------------------------------------------'
  18. echo "A c-shell script for installing dynamical system classes for ${oldpackagename}"
  19. echo "written by Swan Kim 5/1989, revised 8/1989"
  20. echo '------------------------------------------------------------------------------'
  21. echo ''
  22. echo '------------------------------------------------------------------------------'
  23. echo "current home directory: ${oldhomedir}"
  24. echo "current top directory: ${oldtopdir}"
  25. echo "current package name: ${oldpackagename}"
  26. echo "current printer name: ${oldprintername}"
  27. echo "current sun operation system: ${oldsunos}"
  28. echo "current floating point flag: ${oldfpflags}"
  29. echo "current math library flag: ${oldmathlibs}"
  30. echo '------------------------------------------------------------------------------'
  31. echo ''
  32. echo 'NOTE: IF these are NOT what you want, please run ${oldpackagename}_install'
  33. echo 'first and run this shell script afterwards'
  34. echo ''
  35.  
  36. # dynamical system class related variables
  37. set dsclasses = `grep DSCLASSES installcap`
  38. set oldclass = `grep CURCLASS installcap| awk '{print $2}'`
  39. set newclass = ${oldclass}
  40. set copyclass = ${oldclass}
  41. #a class dependent
  42. set classfile =
  43. #a set of suffix for class dependent files
  44. set classfiles = (_f.c _func.c _choose_algorithm.c _${oldpackagename}_init.h _${oldpackagename}_def.h)
  45. #header name of temporary class dependent files
  46. set tmpname = class
  47.  
  48. echo "write temporary installcap file"
  49. cp installcap installcap.tmp
  50.  
  51. echo ''
  52. echo '------------------------------------------------------------------------------'
  53. echo "Currently available dynamical system classes: ${dsclasses[2-]}"
  54. echo "Currently selected: ${oldclass}."
  55. echo '------------------------------------------------------------------------------'
  56. echo ''
  57.  
  58. echo '------------------------------------------------------------------------------'
  59. echo "Enter q or quit to quit the program at any stage"
  60. echo '------------------------------------------------------------------------------'
  61. echo "Enter 1 to create a new dynamical system class"
  62. echo "Enter 2 to remove an existing dynamical system class"
  63. echo "Enter 3 to change a currently selected dynamical system class"
  64. echo '------------------------------------------------------------------------------'
  65. echo ''
  66. echo -n "What do you want? [[q]/1/2/3] "
  67. set task = $<
  68. echo ''
  69. switch(${task})
  70.     case '1':
  71.         goto start_new_loop
  72.         breaksw
  73.     case '2':
  74.         goto start_remove_loop
  75.         breaksw
  76.     case '3':
  77.         goto start_choose_loop
  78.         breaksw
  79.     case 'q':
  80.     case 'quit':
  81.     default:
  82.         goto task_done
  83.         breaksw
  84. endsw
  85.  
  86. start_new_loop:
  87.     set newclass = ${oldclass}
  88.  
  89. echo -n "Create a new class with the name of: " 
  90. set newclass = $<
  91. switch(${newclass})
  92. case '':
  93.     echo "Empty name\!"
  94.     goto start_new_loop
  95.     breaksw
  96. case 'q':
  97. case 'quit':
  98.     goto task_done
  99.     breaksw
  100. default:
  101.     set found = no
  102.     foreach tmpclass (${dsclasses[2-]})
  103.         if($newclass == $tmpclass) then
  104.             set found = yes
  105.             break
  106.         endif
  107.     end
  108.     if($found == 'yes') then
  109.         echo ''
  110.         echo "This class already exists."
  111.         echo 'Try again.'
  112.         echo ''
  113.         goto start_new_loop
  114.     else
  115.     start_copy_loop:
  116.         echo ''
  117.         echo -n "Create a new class as a copy of: "
  118.         set copyclass = $<
  119.         set found = no
  120.         foreach tmpclass (${dsclasses[2-]})
  121.             if($copyclass == $tmpclass) then
  122.                 set found = yes
  123.                 break
  124.             endif
  125.         end
  126.         if($found == 'yes') then
  127.             foreach classfile ($classfiles)
  128.                 cp ${oldtopdir}/modellib/${copyclass}${classfile} ${oldtopdir}/modellib/${newclass}${classfile}
  129.                 cp ${oldtopdir}/modellib/${newclass}${classfile} ${oldtopdir}/modellib/${tmpname}${classfile}
  130.             end
  131.             echo ''
  132.             echo -n "Copy done\! Writing installcap file..."
  133.             cat > "${oldtopdir}/installcap.tmp" <<END
  134. HOMEDIR ${oldhomedir}
  135. PACKAGEDIR ${oldpackagedir}
  136. TOPDIR ${oldtopdir}
  137. PACKAGENAME ${oldpackagename}
  138. PRINTERNAME ${oldprintername}
  139. SUNOS ${oldsunos}
  140. FPFLAGS ${oldfpflags}
  141. MATHLIBS ${oldmathlibs}
  142. DSCLASSES ${dsclasses[2-]} ${newclass}
  143. CURCLASS ${newclass}
  144. END
  145. echo Done!
  146. echo ''
  147.  
  148.         else
  149.             echo ''
  150.             echo "This class does not exist."
  151.             echo 'Try again.'
  152.             echo ''
  153.             goto start_copy_loop
  154.         endif
  155.     endif
  156.     breaksw
  157. endsw
  158.  
  159. end_new_loop:
  160. goto end_remove_loop
  161.  
  162.  
  163. start_remove_loop:
  164. echo -n "Remove a dynamical system class with the name of: " 
  165. set newclass = $<
  166. switch(${newclass})
  167. case '':
  168.     echo 'Empty name\!'
  169.     goto start_remove_loop
  170.     breaksw
  171. case 'q':
  172. case 'quit':
  173.     goto task_done
  174.     breaksw
  175. case ${oldclass}:
  176.     echo "To remove the currently selected dynamical system,"
  177.     echo "change the current selection to something else and rerun this shell script"
  178.     echo -n "Do you really want to remove the currently installed synamical system class? [yes/[no]] "
  179.     set answer = $<        
  180.     switch($answer)
  181.         case 'y':
  182.         case 'yes':
  183.             goto start_choose_loop
  184.             breaksw
  185.         case '':
  186.         case 'n':
  187.         case 'no':
  188.             goto start_remove_loop
  189.             breaksw
  190.         endsw
  191. breaksw
  192.  
  193. default:
  194.     set found = no
  195.     foreach tmpclass (${dsclasses[2-]})
  196.         if($newclass == $tmpclass) then
  197.             set found = yes
  198.             break
  199.         endif
  200.     end
  201.     if($found == 'yes') then
  202.         echo -n "Do you really want to remove this dynamical system class? [yes/[no]] "
  203.         set answer = $<        
  204.         switch($answer)
  205.             case 'y':
  206.             case 'yes':
  207.                 breaksw
  208.             case '':    
  209.             case 'n':
  210.             case 'no':
  211.                 goto start_remove_loop
  212.                 breaksw
  213.         endsw
  214.         unalias rm
  215.         rm -f ${oldtopdir}/*${newclass} ${oldtopdir}/*lib/*${newclass}
  216.         alias rm rm -i
  217.         cat > "${oldtopdir}/installcap.tmp" <<END
  218. HOMEDIR ${oldhomedir}
  219. PACKAGEDIR ${oldpackagedir}
  220. TOPDIR ${oldtopdir}
  221. PACKAGENAME ${oldpackagename}
  222. PRINTERNAME ${oldprintername}
  223. SUNOS ${oldsunos}
  224. FPFLAGS ${oldfpflags}
  225. MATHLIBS ${oldmathlibs}
  226. DSCLASSES ${dsclasses[2-]}
  227. CURCLASS ${oldclass}
  228. END
  229. cat installcap.tmp | sed -e "s/${newclass}//" > installcap
  230. cp installcap installcap.tmp
  231. echo Done!
  232. echo ''
  233.         goto end_remove_loop
  234.     else
  235.         echo "This class does not exist. Try again\!"
  236.         echo ''
  237.         echo '------------------------------------------------------------------------------'
  238.         echo "Currently available dynamical system classes: ${dsclasses[2-]}"
  239. echo '------------------------------------------------------------------------------'
  240.         goto start_remove_loop
  241.     endif
  242.     breaksw
  243. endsw
  244.  
  245. end_remove_loop:
  246.  
  247. echo ''
  248. echo -n "Do you want to change the current selection of dynamical system classes? [yes/[no]] "
  249. set answer = $<
  250. switch($answer)
  251. case 'y':
  252. case 'yes':
  253.     breaksw
  254. case 'n':
  255. case 'no':
  256. default:
  257.     set newclass = ${oldclass}
  258.     goto end_choose_loop
  259.     breaksw
  260. endsw
  261.  
  262. #------------------------------------------------------------------------
  263. set dsclasses = `grep DSCLASSES installcap.tmp`
  264. echo ''
  265. echo ''
  266. echo "Currently avaiable dynamical system classes: ${dsclasses[2-]}"
  267. echo ''
  268.  
  269. start_choose_loop:
  270. echo ''
  271. echo -n "Choose a desired class to be installed: "
  272. set newclass = $<
  273. switch($newclass)
  274. default:
  275.     set found = no
  276.     foreach tmpclass (${dsclasses[2-]})
  277.         if($newclass == $tmpclass) then
  278.             set found = yes
  279.             break
  280.         endif
  281.     end
  282.     if($found == 'yes') then
  283.         echo "Copying files..."
  284.         foreach classfile ($classfiles)
  285.             cp ${oldtopdir}/modellib/${copyclass}${classfile} ${oldtopdir}/modellib/${newclass}${classfile}
  286.             cp ${oldtopdir}/modellib/${newclass}${classfile} ${oldtopdir}/modellib/${tmpname}${classfile}
  287.         end
  288.     else
  289.         echo ''
  290.         echo "This class is not found in the list."
  291.         echo 'Try again.'
  292.         echo ''
  293.         goto start_choose_loop
  294.     endif
  295.     breaksw
  296. endsw
  297.  
  298. echo ''
  299. echo -n "Writing installcap file..."
  300. cat > "${oldtopdir}/installcap.tmp" <<END
  301. HOMEDIR ${oldhomedir}
  302. PACKAGEDIR ${oldpackagedir}
  303. TOPDIR ${oldtopdir}
  304. PACKAGENAME ${oldpackagename}
  305. PRINTERNAME ${oldprintername}
  306. SUNOS ${oldsunos}
  307. FPFLAGS ${oldfpflags}
  308. MATHLIBS ${oldmathlibs}
  309. CURCLASS ${newclass}
  310. DSCLASSES ${dsclasses[2-]}
  311. END
  312. echo Done!
  313.  
  314. end_choose_loop:
  315.  
  316.  
  317. echo ''
  318. if (${newclass} == ${oldclass}) then
  319.     echo "Newly selected class ${newclass} is the same as the old one."
  320.     echo -n "Do you still want to compile and install the new class? [yes/[no]] "
  321. else
  322.     echo "Newly selected class: ${newclass} (Yet to be compiled)"
  323.     echo "Old class: ${oldclass}   (Already compiled)"
  324.     echo ''
  325.     echo -n "Do you want to compile and install the new class? [yes/[no]] "
  326. endif
  327.  
  328. set answer = $<
  329. switch($answer)
  330. case 'y':
  331. case 'yes':
  332.     breaksw
  333. case 'n':
  334. case 'no':
  335. default:
  336.     goto end_make_loop
  337.     breaksw
  338. endsw
  339.  
  340. start_install_loop:
  341. echo ''
  342. echo -n "Install the program with the name of: "
  343. set newpackagename = $<
  344. switch($newpackagename)
  345. case '':
  346.     echo 'Empty name\!'
  347.     goto start_install_loop
  348.     breaksw
  349. default:
  350.  
  351. #
  352. # acutal compilation and installation of the new dynamical system class
  353. #
  354.     echo ''
  355.     echo "${newpackagename} is being installed..."
  356.     echo ''
  357.     echo ''
  358.     unalias mv
  359.     cd ${oldtopdir}
  360.     if( -f ${oldpackagename}) then
  361.         mv -f ${oldpackagename} ${oldpackagename}.tmp
  362.         make ${oldpackagename}
  363.         mv -f ${oldpackagename} ${newpackagename}
  364.         mv -f ${oldpackagename}.tmp ${oldpackagename})
  365.     else
  366.         make ${oldpackagename}
  367.         mv -f ${oldpackagename} ${newpackagename}
  368.     endif
  369.     cd ${curdir}
  370.     alias mv mv -i
  371.     breaksw
  372. endsw
  373.  
  374. echo ''
  375. echo Done!
  376. echo ''
  377.  
  378. end_make_loop:
  379.  
  380. #
  381. # move the temporary file to installcap
  382. #
  383. unalias mv
  384. mv -f installcap.tmp installcap
  385. alias mv mv -i
  386.  
  387. task_done:
  388. echo ''
  389. echo 'Exiting the shell script...'
  390. echo ''
  391.